package net.maku.system.controller;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.maku.framework.common.utils.Result;
import net.maku.system.service.SysParamsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("sys/params")
@Tag(name = "参数管理")
@AllArgsConstructor
public class SysParamsController {

    private final SysParamsService sysParamsService;

    @GetMapping("getIndexNavList")
    @Operation(summary = "获取首页的导航列表")
    public Result getIndexNavList(){
        String key = "jingangList";
        String key2 = "jingangList2";
        String list1 = sysParamsService.getString(key);
        String list2 = sysParamsService.getString(key2);
        JSONArray  jingangList = JSON.parseArray(list1);
        JSONArray jingangList2 = JSON.parseArray(list2);
        Map<String,Object> map = new HashMap<>();
        map.put("jingangList",jingangList);
        map.put("jingangList2",jingangList2);
        return Result.ok(map);
    }

    @GetMapping("getActivityCenterList")
    @Operation(summary = "活动中心的导航列表")
    public Result getActivityCenterList(){
        String key = "activityCenterList";
        String list = sysParamsService.getString(key);
        JSONArray  objects = JSON.parseArray(list);
        return Result.ok(objects);
    }

    @GetMapping("getStaffCenterList")
    @Operation(summary = "获取职工中心导航列表")
    public Result getStaffCenterList(){
        String key = "staffCenterList";
        String list = sysParamsService.getString(key);
        JSONArray  objects = JSON.parseArray(list);
        return Result.ok(objects);
    }

}
